local shanduan = fk.CreateSkill{
    name = "heg__shanduan",
}

Fk:loadTranslationTable{
    ["heg__shanduan"] = "善断",
    [":heg__shanduan"] = "准备阶段，你可以令你本回合以下一项数值调整为你的体力值：<br>"..
    "1.本回合摸牌阶段摸牌数；<br>"..
    "2.本回合攻击范围；<br>"..
    "3.使用【杀】次数上限。",
    ["heg__shanduan__drawcards"] = "摸牌阶段摸牌数",
    ["heg__shanduan__attackrange"] = "攻击范围",
    ["heg__shanduan__slash"] = "次数上限",
    ["@heg__shanduan_drawcards-turn"] = "摸牌数",
    ["@heg__shanduan_attackrange-turn"] = "攻击范围",
    ["@heg__shanduan_slash-turn"] = "【杀】次数上限",

    ["$heg__shanduan1"] = "浪子回头，其期未晚矣！",
    ["$heg__shanduan2"] = "心既存蛟虎，秉慧剑斩之！",
}

shanduan:addEffect(fk.EventPhaseStart,{
    anim_type = "support",
    can_trigger = function (self, event, target, player, data)
        return target == player and player:hasSkill(shanduan.name) and player.phase == Player.Start
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local choices = {"heg__shanduan__drawcards","heg__shanduan__attackrange","heg__shanduan__slash"}
        local choice = room:askToChoice(player,{
            choices = choices,
            skill_name = shanduan.name,
            cancelable = false,
        })
        if choice == "heg__shanduan__drawcards" then
            room:setPlayerMark(player, "@"..shanduan.name.."_drawcards-turn", player.hp)
        elseif choice == "heg__shanduan__attackrange" then
            room:setPlayerMark(player, "@"..shanduan.name.."_attackrange-turn", player.hp)
        else
            room:setPlayerMark(player, "@"..shanduan.name.."_slash-turn", player.hp)
        end
    end,
})


shanduan:addEffect("atkrange",{
    fixed_func = function (self, from)
        if from:getMark("@"..shanduan.name.."_attackrange-turn") > 0 then
        return from:getMark("@"..shanduan.name.."_attackrange-turn")
      end
    end,
})

shanduan:addEffect("targetmod", {
    fix_times_func = function (self, player, skill, scope, card, to)
    if skill.trueName == "slash_skill" and scope == Player.HistoryPhase and player:getMark("@"..shanduan.name.."_slash-turn") > 0 then
        return player:getMark("@"..shanduan.name.."_slash-turn")
      end
    end,
})

shanduan:addEffect(fk.DrawNCards, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("@"..shanduan.name.."_drawcards-turn") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    data.n = player:getMark("@"..shanduan.name.."_drawcards-turn")
  end,
})

return shanduan